<% dim adoResYear dim lngMakeId dim lngYearId dim strFromYear dim srtToYear Set adoResYear = CreateObject("ADODB.Recordset") adoResYear.CursorLocation = 3 ' adUseClient Set adoResFrom = CreateObject("ADODB.Recordset") adoResFrom.CursorLocation = 3 ' adUseClient Set adoResTo = CreateObject("ADODB.Recordset") adoResTo.CursorLocation = 3 ' adUseClient lngMakeId = Request("MakeId") lngYearId = Request("YearId") if lngMakeId="" then lngMakeId=0 if lngYearId="" then lngYearId=0 strYear = "" 'get from year by make id strSQL = "SELECT MIN(Years.YearName) AS FromYear" & _ " FROM Product_Make INNER JOIN" & _ " Years ON Product_Make.FromYearId = Years.YearId" & _ " WHERE (Product_Make.MakeId = "& lngMakeId &")" Set adoResFrom = objConn.Execute(strSQL) if not adoResFrom.eof then strFromYear = adoResFrom.fields("FromYear") 'get from year id adoResFrom.close strSQL = "select YearID from Years where YearName = '" & strFromYear & "'" adoResFrom.Open strSQL, objConn, adOpenStatic, adLockOptimistic if not adoResFrom.eof then lngFromYearId = adoResFrom.fields("YearID") else lngFromYearId = 0 end if 'get toyear strSQL = "SELECT Years.YearName" & _ " FROM Product_Make INNER JOIN" & _ " Years ON Product_Make.ToYearId = Years.YearId" & _ " WHERE (Product_Make.MakeId = "& lngMakeId &") AND (Years.YearName = '+')" Set adoResTo = objConn.Execute(strSQL) if not adoResTo.eof then strToYear = Year(now) adoResTo.close 'get to year id strSQL = "select YearID from Years where YearName = '" & strToYear & "'" adoResTo.Open strSQL, objConn, adOpenStatic, adLockOptimistic if not adoResTo.eof then lngToYearId = adoResTo.fields("YearID") else lngToYearId = 0 end if else adoResTo.close strSQL = "SELECT MAX(Years.YearName) AS ToYear" & _ " FROM Product_Make INNER JOIN" & _ " Years ON Product_Make.ToYearId = Years.YearId" & _ " WHERE (Product_Make.MakeId = "& lngMakeId &")" Set adoResTo = objConn.Execute(strSQL) if not adoResTo.eof then strToYear = adoResTo.fields("ToYear") adoResTo.close 'get to year id strSQL = "select YearID from Years where YearName = '" & strToYear & "'" adoResTo.Open strSQL, objConn, adOpenStatic, adLockOptimistic if not adoResTo.eof then lngToYearId = adoResTo.fields("YearID") else lngToYearId = 0 end if else adoResTo.close strToYear = strFromYear lngToYearId = lngFromYear end if end if else adoResFrom.close end if %> StopTech
<% set adoResYear = nothing %>